package org.bing.engine.common.scheduler;

import org.bing.engine.common.logging.Log;
import org.bing.engine.common.logging.LogFactory;

public abstract class AbstractTask implements Runnable {
    protected static final Log logger = LogFactory.getLog(AbstractTask.class);
    private String begin;
    private String end;
    private int period;
    private boolean integral;

    public final void run() {
        try {
            if (logger.isDebugEnabled()) {
                logger.debug(" - start task " + this.getClass().getSimpleName());
            }
            doTask();
        } catch (Throwable e) {
            logger.error("Fail to run task ", e);
        }
    }

    public abstract void doTask();

    public String getBegin() {
        return begin;
    }

    public void setBegin(String begin) {
        this.begin = begin;
    }

    public String getEnd() {
        return end;
    }

    public void setEnd(String end) {
        this.end = end;
    }

    public int getPeriod() {
        return period;
    }

    public void setPeriod(int period) {
        this.period = period;
    }

    public boolean isIntegral() {
        return integral;
    }

    public void setIntegral(boolean integral) {
        this.integral = integral;
    }

}
